package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class AddOperation implements IOpeartion {

    @Override
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("新增图书");
        System.out.println("请输入新增书名：");
        String name = scanner.nextLine();
        System.out.println("请输入作者：");
        String author = scanner.nextLine();
        System.out.println("请输入类型：");
        String type = scanner.nextLine();

        System.out.println("请输入价格：");
        int price = scanner.nextInt();

        int curSize = bookList.getUsedSize();//没插入前书的大小
        Book book =new Book(name,author,price,type);
        int pos = bookList.getUsedSize();
        bookList.setBooks(pos,book);
        bookList.setUsedSize(curSize+1);//插入后书大小+1

    }
}
